var t, a = require("../../@babel/runtime/helpers/defineProperty"), e = getApp();

Page({
    data: (t = {
        active: 0,
        activeOne: 0,
        listData: [],
        info: []
    }, a(t, "active", 0), a(t, "activeOne", 0), a(t, "listData", []), a(t, "user_assets", 0), 
    a(t, "show", !1), a(t, "isLoadMore", !0), a(t, "page", 1), a(t, "total_page", 0), 
    t),
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "钱包"
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getInfo();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    resrtTap: function(t) {
        console.log(t), this.init(), this.setData({
            active: t.detail.index
        }), this.getData();
    },
    init: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            listData: []
        });
    },
    getInfo: function() {
        var t = this, a = e.getNetAddresss("plugin.love-speed-pool.frontend.wallet.index");
        e._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    info: e.data.tabs,
                    show: !0
                }), t.getData()) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, a = {
            value: 1 == this.data.active ? 1 : 2 == this.data.active ? 2 : 0,
            page: this.data.page
        }, o = e.getNetAddresss("plugin.love-speed-pool.frontend.wallet.getValueData");
        e._getNetWork({
            url: o,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.data.total_page = e.data.records.last_page, 
                t.data.total_page || (t.data.total_page = 0), t.setData({
                    listData: e.data.records.data,
                    user_assets: e.data.user_assets
                }), t.data.listData && t.data.listData.length > 0 && (t.data.listData.forEach(function(a) {
                    a.format_time = t.timestamp(a.create_at);
                }), t.setData({
                    listData: t.data.listData
                }))) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    timestamp: function(t) {
        var a = "";
        a = t < 1e12 ? 1e3 * t : t;
        var e = new Date(a);
        return e.getFullYear() + "." + this.supplement(e.getMonth() + 1) + "." + this.supplement(e.getDate()) + "  " + this.supplement(e.getHours()) + ":" + this.supplement(e.getMinutes());
    },
    supplement: function(t) {
        return t < 10 ? "0" + t : t;
    },
    getMoreData: function() {
        var t = this, a = "";
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var o = {
                value: this.data.info[0 == this.data.active ? "currency_1" : "currency_2"].value,
                page: this.data.page
            };
            a = e.getNetAddresss("plugin.love-speed-pool.frontend.wallet.getValueData"), e._postNetWork({
                url: a,
                data: o,
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.data.isLoadMore = !0, t.setData({
                        listData: t.data.listData.concat(e.data.records.data)
                    })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    pay: function(t) {
        var a = t.currentTarget.dataset.info;
        0 == a.value ? wx.navigateTo({
            url: "/packageB/member/love/loveWithdrawals/loveWithdrawals"
        }) : wx.navigateTo({
            url: "/packageF/love_transform/love_transform?value=" + a.value
        });
    }
});